<?php

/** @noinspection PhpMissingFieldTypeInspection */
/** @noinspection PhpUnusedFieldDefaultValueInspection */
/** @noinspection PhpUnused */
/** @noinspection PhpMissingParamTypeInspection */
/** @noinspection PhpPropertyOnlyWrittenInspection */
/** @noinspection PhpUnusedPrivateFieldInspection */
/** @noinspection PhpMissingParamTypeInspection */

namespace DreamCat\Array2Class\Demo;

use JetBrains\PhpStorm\Pure;

/**
 * 带静态属性的PO
 * @author vijay
 */
class WithStaticPo
{
    /** @var string - */
    private static $name;
    /** @var string - */
    private $error = "noConstruct";

    /**
     * WithStaticPo constructor.
     * @param string $error -
     */
    public function __construct($error)
    {
        $this->error = "onConstruct: {$error}";
    }

    /**
     * 便于构建的构建函数
     * @param string $error -
     * @param array $values -
     * @return static
     */
    #[Pure]
    public static function builder($error = "builder", array $values = []): self
    {
        $obj = new static($error);
        foreach ($values as $key => $val) {
            /** @noinspection PhpVariableVariableInspection */
            $obj->$key = $val;
        }
        return $obj;
    }
}

# end of file
